#include <cmath>
#include <iostream>

#include "point.h"

//#define ERROR 0.00001

Point::Point(){
	this->x = 0.0;
	this->y = 0.0;
}

Point::Point(int x, int y){
	this->x = x;
	this->y = y;
}

Point::Point(const Point& v){
	this->x = v.x;
	this->y = v.y;
}

Point::~Point(){
}

Point Point::operator-(const Point& _v){
	return Point(this->x - _v.x, this->y - _v.y);
}

Point Point::operator+(const Point& _v){
	return Point(this->x + _v.x, this->y + _v.y);
}

Point Point::operator*(double _lambda){
	return Point(this->x*_lambda, this->y*_lambda);
}

bool Point::operator==(const Point& _v){
    if((x == _v.x) && (y == _v.y)) return true;
	else return false;
}

double Point::length(){
	return sqrt(this->dotProduct(*this));
}

double Point::dotProduct(Point _v){
	return (this->x*_v.x) + (this->y*_v.y);
}

double Point::crossProductLength(Point _v){
    double z = this->x*_v.y - this->y*_v.x;
	return sqrt(z*z);//como eh elevado ao quadrado e dpeois tirado a raiz... corta
}
